﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;


namespace footwear
{
    public partial class ListProduct : System.Web.UI.Page
    {

        public CategoryBus categoryBus = new CategoryBus();
        public ShoeInfoBus shoeInfoBus = new ShoeInfoBus();
        public List<Category> listCategoryShowIndex;
        public List<ShoeInfo> listCategory1;
        public List<ShoeInfo> listCategory2;
        public List<ShoeInfo> listCategory3;
        public List<ShoeInfo> listCategory4;
        public List<ShoeInfo> list;
        public string name;

        protected void Page_Load(object sender, EventArgs e)
        {
            if (DbConnect.Connection == null)
            {
                var dbConnect = new DbConnect();
            }
            listCategoryShowIndex = categoryBus.GetListCategoryShowIndex();
            listCategory1 = shoeInfoBus.GetListShoesShowIndexByCategory(listCategoryShowIndex[0].Type);
            listCategory2 = shoeInfoBus.GetListShoesShowIndexByCategory(listCategoryShowIndex[1].Type);
            listCategory3 = shoeInfoBus.GetListShoesShowIndexByCategory(listCategoryShowIndex[2].Type);
            listCategory4 = shoeInfoBus.GetListShoesShowIndexByCategory(listCategoryShowIndex[3].Type);
            if (Request.QueryString["category"] != "all")
            {
                name = categoryBus.GetType(Convert.ToInt32(Request.QueryString["category"]));
            }
            else {
                name = "Tất cả";
            }
            list = Request.QueryString["category"] == "all" ? shoeInfoBus.GetAllShoeItem() : shoeInfoBus.GetListShoesByCategory(name);

        }
    }
}